package com.jiuwu.spring.eshop.respository;

import com.jiuwu.spring.eshop.db.entity.VGoods;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface VGoodsRepository extends BaseRepository<VGoods,Integer> {

    List<VGoods>  findTop3BySoldTotalGreaterThanEqualOrderBySoldTotalDesc(int soldTotal);


    List<VGoods> findAllByIsNewEquals(int isNew);


    List<VGoods> findAllByIsSaleEquals(int isSale);


    List<VGoods> findAllByGoodsNameLike(String goodsName);


    List<VGoods> findAllByGoodsNameLikeAndSubIdIn(String goodsName,List<Integer> goodsId);


    List<VGoods> findAllBySubIdEquals(Integer subId);

    @Query("select g.goodsId,g.goodsName,t.superType,t.subType from VGoods  g left join VType t on g.subId = t.subID")
    List<Object[]> findGoodsWithType();

}
